Hệ thống quản lý phòng khám trực tuyến bằng PHP

1 <?php if(!isset($Translation)){ @header('Location: index.php'); exit; } ?>
2
3 <div
class="page-header"><h1>
4     <span id=
"table-title-img"><img align="top" src="<?php echo $this->TableIcon; ?>" /></span> <?php echo $this->TableTitle . " " . $Translation['filters']; ?>
5 </h1></div>
6
7 <?php
8     
/* SPM link for admin */
9     
if(getLoggedAdmin()){
10         $spm_installed =
false;
11         $plugins = get_plugins();
12         
foreach($plugins as $pl){
13             
if($pl['title'] == 'Search Page Maker') $spm_installed = true;
14         }
15
16         
if(!$spm_installed) echo Notification::show(array(
17             
'message' => '<i class="glyphicon glyphicon-info-sign"></i> Wish to offer your users an easier, more-tailored search experience? <a href="https://bigprof.com/appgini/applications?search-page-maker-plugin-discount" target="_blank" class="alert-link"><i class="glyphicon glyphicon-hand-right"></i> Click here to learn how Search Page Maker plugin can help</a>.',
18             
'dismiss_days' => 30,
19             
'class' => 'success',
20             
'id' => 'spm_notification'
21         ));
22     }
23 ?>
24
25 <!-- checkboxes
for parent filterers -->
26 <?php
27     
foreach($this->filterers as $filterer => $caption){
28         $fltrr_name =
'filterer_' . $filterer;
29         $fltrr_val = $_REQUEST[$fltrr_name];
30         
if($fltrr_val != ''){
31             ?>
32             <div
class="row">
33                 <div
class="col-md-offset-3 col-md-7">
34                     <div
class="checkbox">
35                         <label>
36                             <input type=
"checkbox" id="<?php echo $fltrr_name; ?>" name="<?php echo $fltrr_name; ?>" value="<?php echo html_attr($fltrr_val); ?>" checked>
37                             <strong><?php printf($Translation[
'Only show records having filterer'], $caption, "<span class=\"text-info\" id=\"{$fltrr_name}_display_value\"></span>"); ?></strong>
38                         </label>
39                         <script>
40                             jQuery(function() {
41                                 jQuery.ajax({
42                                     url:
'ajax_combo.php',
43                                     dataType:
'json',
44                                     data: { id:
'<?php echo addslashes($fltrr_val); ?>', t: '<?php echo $this->TableName; ?>', f: '<?php echo $filterer; ?>', o: 0 }
45                                 }).done(function(resp){
46                                     jQuery(
'#<?php echo $fltrr_name; ?>_display_value').html(resp.results[0].text);
47                                 });
48                             });
49                         </script>
50                     </div>
51                 </div>
52             </div>
53             <?php
54             
break; // currently, only one filterer can be applied at a time
55         }
56     }
57 ?>
58
59
60 <!-- filters header -->
61 <div
class="row hidden-sm hidden-xs" style="border-bottom: solid 2px #DDD;">
62     <div
class="col-md-2 col-md-offset-4 vspacer-lg"><strong><?php echo $Translation['filtered field']; ?></strong></div>
63     <div
class="col-md-2 vspacer-lg"><strong><?php echo $Translation['comparison operator']; ?></strong></div>
64     <div
class="col-md-2 vspacer-lg"><strong><?php echo $Translation['comparison value']; ?></strong></div>
65 </div>
66
67
68 <!-- filter groups -->
69 <?php
70     
for($i = 1; $i <= (3 * $FiltersPerGroup); $i++){ // Number of filters allowed
71         $fields =
'';
72         $operators =
'';
73
74         
if(($i % $FiltersPerGroup == 1) && $i != 1){
75             $seland =
new Combo;
76             $seland->ListItem = array($Translation[
"or"], $Translation["and"]);
77             $seland->ListData = array(
"or", "and");
78             $seland->SelectName =
"FilterAnd[$i]";
79             $seland->SelectedData = $FilterAnd[$i];
80             $seland->Render();
81             ?>
82             <!-- how to combine next
group with previous one: and/or? -->
83             <div
class="row FilterSet<?php echo ($i - 1); ?>" style="border-bottom: dotted 1px #DDD;">
84                 <div
class="col-md-5 vspacer-md"></div>
85                 <div
class="col-md-2 vspacer-md">
86                     <?php echo $seland->HTML; ?>
87                 </div>
88             </div>
89         <?php } ?>
90
91         <!-- filter rule -->
92         <div
class="row FilterSet<?php echo $i; ?>" style="border-bottom: dotted 1px #DDD;">
93             <div
class="col-md-2 vspacer-md"></div>
94             <div
class="col-md-1 text-right hidden-sm hidden-xs vspacer-md"><strong><?php echo $Translation["filter"] . sprintf(" %02d", $i); ?></strong></div>
95             <div
class="col-md-1 hidden-md hidden-lg vspacer-md"><strong><?php echo $Translation["filter"] . sprintf(" %02d", $i); ?></strong></div>
96             <div
class="col-md-1 vspacer-md">
97                 <?php
98                     
// And, Or select
99                     
if($i % $FiltersPerGroup != 1){
100                         $seland =
new Combo;
101                         $seland->ListItem = array($Translation[
"and"], $Translation["or"]);
102                         $seland->ListData = array(
"and", "or");
103                         $seland->SelectName =
"FilterAnd[$i]";
104                         $seland->SelectedData = $FilterAnd[$i];
105                         $seland->Render();
106                         echo $seland->HTML;
107                     }
108                 ?>
109             </div>
110             <div
class="col-md-2 vspacer-md">
111                 <?php
112                     
// Fields list
113                     $selfields =
new Combo;
114                     $selfields->SelectName =
"FilterField[$i]";
115                     $selfields->SelectedData = $FilterField[$i];
116                     $selfields->ListItem = array_values($
this->QueryFieldsFilters);
117                     $selfields->ListData = array_keys($
this->QueryFieldsIndexed);
118                     $selfields->Render();
119                     echo $selfields->HTML;
120                 ?>
121             </div>
122             <div
class="col-md-2 vspacer-md">
123                 <?php
124                     
// Operators list
125                     $selop =
new Combo;
126                     $selop->ListItem = array($Translation[
"equal to"], $Translation["not equal to"], $Translation["greater than"], $Translation["greater than or equal to"], $Translation["less than"], $Translation["less than or equal to"] , $Translation["like"] , $Translation["not like"], $Translation["is empty"], $Translation["is not empty"]);
127                     $selop->ListData = array_keys($GLOBALS[
'filter_operators']);
128                     $selop->SelectName =
"FilterOperator[$i]";
129                     $selop->SelectedData = $FilterOperator[$i];
130                     $selop->Render();
131                     echo $selop->HTML;
132                 ?>
133             </div>
134             <div
class="col-md-2 vspacer-md">
135                 <?php
/* Comparison expression */ ?>
136                 <input name=
"FilterValue[<?php echo $i; ?>]" value="<?php echo html_attr($FilterValue[$i]); ?>" class="form-control">
137             </div>
138             <div
class="col-md-2 vspacer-md">
139                 <button type=
"button" class="btn btn-default clear_filter" id="filter_<?php echo $i; ?>"><i class="glyphicon glyphicon-trash text-danger"></i></button>
140             </div>
141         </div>
142         <?php
143     }
144 ?>
145
146 <script>
147     $j(function(){
148         $j(
'.clear_filter').click(function(){
149             
var filt_num = $j(this).attr('id').replace(/^filter_/, '');
150             $j(
'#FilterAnd_' + filt_num + '_').select2('val', '');
151             $j(
'#FilterField_' + filt_num + '_').select2('val', '');
152             $j(
'#FilterOperator_' + filt_num + '_').select2('val', '');
153             $j(
'[name="FilterValue[' + filt_num + ']"]').val('');
154         });
155     })
156 </script>
157
158 <!-- sorting header -->
159 <div
class="row" style="border-bottom: solid 2px #DDD;">
160     <div
class="col-md-offset-2 col-md-8 vspacer-lg"><strong><?php echo $Translation['order by']; ?></strong></div>
161 </div>
162
163 <!-- sorting rules -->
164 <?php
165     
// Fields list
166     $sortFields =
new Combo;
167     $sortFields->ListItem = $
this->ColCaption;
168     $sortFields->ListData = $
this->ColNumber;
169
170     
// sort direction
171     $sortDirs =
new Combo;
172     $sortDirs->ListItem = array($Translation[
'ascending'], $Translation['descending']);
173     $sortDirs->ListData = array(
'asc', 'desc');
174     $num_rules = min(maxSortBy, count($
this->ColCaption));
175
176     
for($i = 0; $i < $num_rules; $i++){
177         $sfi = $sd =
'';
178         
if(isset($orderBy[$i])) foreach($orderBy[$i] as $sfi => $sd);
179
180         $sortFields->SelectName =
"OrderByField$i";
181         $sortFields->SelectID =
"OrderByField$i";
182         $sortFields->SelectedData = $sfi;
183         $sortFields->SelectedText =
'';
184         $sortFields->Render();
185
186         $sortDirs->SelectName =
"OrderDir$i";
187         $sortDirs->SelectID =
"OrderDir$i";
188         $sortDirs->SelectedData = $sd;
189         $sortDirs->SelectedText =
'';
190         $sortDirs->Render();
191
192         $border_style = ($i == $num_rules -
1 ? 'solid 2px #DDD' : 'dotted 1px #DDD');
193         ?>
194         <!-- sorting rule -->
195         <div
class="row" style="border-bottom: <?php echo $border_style; ?>;">
196             <div
class="col-xs-2 vspacer-md hidden-md hidden-lg"><strong><?php echo ($i ? $Translation['then by'] : $Translation['order by']); ?></strong></div>
197             <div
class="col-md-2 col-md-offset-2 vspacer-md hidden-xs hidden-sm text-right"><strong><?php echo ($i ? $Translation['then by'] : $Translation['order by']); ?></strong></div>
198             <div
class="col-xs-6 col-md-4 vspacer-md"><?php echo $sortFields->HTML; ?></div>
199             <div
class="col-xs-4 col-md-2 vspacer-md"><?php echo $sortDirs->HTML; ?></div>
200         </div>
201         <?php
202     }
203
204     
// ownership options
205     $mi = getMemberInfo();
206     $adminConfig = config(
'adminConfig');
207     $isAnonymous = ($mi[
'group'] == $adminConfig['anonymousGroup']);
208
209     
if(!$isAnonymous){
210         ?>
211         <!-- ownership header -->
212         <div
class="row filterByOwnership" style="border-bottom: solid 2px #DDD;">
213             <div
class="col-md-offset-2 col-md-8 vspacer-lg"><strong><?php echo $Translation['Records to display']; ?></strong></div>
214         </div>
215
216         <!-- ownership options -->
217         <div
class="row" style="border-bottom: dotted 2px #DDD;">
218             <div
class="col-md-8 col-md-offset-2">
219                 <div
class="radio filterByOwnership">
220                     <label>
221                         <input type=
"radio" name="DisplayRecords" id="DisplayRecordsUser" value="user"/>
222                         <?php echo $Translation[
'Only your own records']; ?>
223                     </label>
224                 </div>
225                 <div
class="radio filterByOwnership">
226                     <label>
227                         <input type=
"radio" name="DisplayRecords" id="DisplayRecordsGroup" value="group"/>
228                         <?php echo $Translation[
'All records owned by your group']; ?>
229                     </label>
230                 </div>
231                 <div
class="radio filterByOwnership">
232                     <label>
233                         <input type=
"radio" name="DisplayRecords" id="DisplayRecordsAll" value="all"/>
234                         <?php echo $Translation[
'All records']; ?>
235                     </label>
236                 </div>
237             </div>
238         </div>
239         <?php
240     }
241 ?>
242
243 <!-- filter actions -->
244 <div
class="row">
245     <div
class="col-md-2 col-md-offset-2 vspacer-lg">
246         <input type=
"hidden" name="apply_sorting" value="1">
247         <button type=
"submit" id="applyFilters" class="btn btn-success btn-block btn-lg"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['apply filters']; ?></button>
248     </div>
249     <?php
if($this->AllowSavingFilters){ ?>
250         <div
class="col-md-3 vspacer-lg">
251             <button type=
"submit" class="btn btn-default btn-block btn-lg" id="SaveFilter" name="SaveFilter_x" value="1"><i class="glyphicon glyphicon-align-left"></i> <?php echo $Translation['save filters']; ?></button>
252         </div>
253     <?php } ?>
254     <div
class="col-md-2 vspacer-lg">
255         <button onclick=
"jQuery('form')[0].reset();" type="submit" id="cancelFilters" class="btn btn-warning btn-block btn-lg"><i class="glyphicon glyphicon-remove"></i> <?php echo $Translation['Cancel']; ?></button>
256     </div>
257 </div>
258
259
260 <script>
261     
var FiltersPerGroup = <?php echo $FiltersPerGroup; ?>;
262
263     function filterGroupDisplay(groupIndex, hide, animate){
264         
for(i = ((groupIndex - 1) * FiltersPerGroup + 1); i <= (groupIndex * FiltersPerGroup); i++){
265             
if(animate){
266                 
if(hide) jQuery('div.FilterSet' + i).fadeOut();
267                 
if(!hide) jQuery('div.FilterSet' + i).fadeIn(function(){
268                     jQuery(
'#FilterField_' + ((groupIndex - 1) * FiltersPerGroup + 1) + '_').focus();
269                 });
270             }
else{
271                 
if(hide) jQuery('div.FilterSet' + i).hide();
272                 
if(!hide) jQuery('div.FilterSet' + i).show(function(){
273                     jQuery(
'#FilterField_' + ((groupIndex - 1) * FiltersPerGroup + 1) + '_').focus();
274                 });
275             }
276         }
277     }
278
279     jQuery(function(){
280         
for(i = (FiltersPerGroup + 1); i <= (3 * FiltersPerGroup); i++){
281             jQuery(
'div.FilterSet' + i).hide();
282         }
283         jQuery(
'#FilterAnd_' + (FiltersPerGroup + 1) + '_').change(function(){
284             filterGroupDisplay(
2, (jQuery(this).val() ? false : true), true);
285         });
286         jQuery(
'#FilterAnd_' + (2 * FiltersPerGroup + 1) + '_').change(function(){
287             filterGroupDisplay(
3, (jQuery(this).val() ? false : true), true);
288         });
289
290         
if(jQuery('#FilterAnd_' + ( FiltersPerGroup + 1) + '_').val()){ filterGroupDisplay(2); }
291         
if(jQuery('#FilterAnd_' + (2 * FiltersPerGroup + 1) + '_').val()){ filterGroupDisplay(3); }
292
293         
var DisplayRecords = '<?php echo html_attr($_REQUEST['DisplayRecords']); ?>';
294
295         
switch(DisplayRecords){
296             
case 'user':
297                 jQuery(
'#DisplayRecordsUser').prop('checked', true);
298                 
break;
299             
case 'group':
300                 jQuery(
'#DisplayRecordsGroup').prop('checked', true);
301                 
break;
302             
default:
303                 jQuery(
'#DisplayRecordsAll').prop('checked', true);
304         }
305     });
306 </script>


Gõ tìm kiếm nhanh...